<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Twoir\Anroute\Routing\Router;
use Twoir\Anroute\Routing\RouteDispatcher;

$router = new Router();
$router->registerControllers(['App\Controllers']);

// // 示例生成 URL
// echo "User Index: " . route($router, 'user.index', [], ['page' => 2]) . "\n";
// // 输出: /admin/users?page=2

// echo "User Show: " . route($router, 'user.show', ['id' => 123], ['sort' => 'asc']) . "\n";
// // 输出: /admin/users/123?sort=asc

$dispatcher = new RouteDispatcher();
$dispatcher->dispatch($router->getRoutes(), $_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD']);
